from enum import Enum

from fastapi import FastAPI


app = FastAPI()


@app.get("/hello")
async def hello():
    """
    简单使用：
        app 是FastAPI的实例， 所有的操作都是通过app来实现
    """
    return {
        "code": 200,
        "message": "hello"
    }


@app.get("/get/Admin")
async def get_by_name2():
    """
        如果url有重叠部分, 排在前面的优先级更高
    :return:
    """
    return {
        "code": 200,
        "message": "Hello Admin"
    }


@app.get("/get/{name}")
async def get_by_name3(name: int):
    """
        可以在参数中指定参数类型
    :param name:
    :return:
    """
    return {
        "code": 200,
        "message": "get_by_name3 " + str(name)
    }


@app.get("/get/{name}")
async def get_by_name1(name: str):
    return {
        "code": 200,
        "message": "Hello" + name
    }


class ModelName(str, Enum):
    alexnet = "alexnet"
    resnet = "resnet"
    lenet = "lenet"
